import { request } from '@/utils/request'
import type {OrderCreateParams} from "./types.ts"

const baseUrl = '/api/user/order'

/* 创建订单 */
export const createOrderApi = ()=> {
	return request({
		url: baseUrl + '/pre',
		method: 'GET'
	})
}

/* 立即购买 */
export const nowBuyOrderApi = (data:{
	skuId: string,
	count: string | number,
	addressId?: string
})=> {
	return request({
		url: baseUrl + '/pre/now',
		method: 'GET',
		data
	})
}

/* 生成订单 */

export const addOrderApi = (data: OrderCreateParams)=>{
	return request<{id:string}>({
		url: baseUrl,
		method: 'POST',
		data
	})
}